# import os
# import Application.Common.function
# from flask import Flask
# from flask import render_template
# from flask import request
# from flask import redirect
# from flask import url_for
# from werkzeug import secure_filename
#
# from flask.ext.wtf import Form
# from wtforms import StringField, BooleanField
# from wtforms.validators import DataRequired
#
# from flask.ext.sqlalchemy import SQLAlchemy
# app = Flask(__name__)
# db = SQLAlchemy(app)
# app.config.from_object('config')
#
# #from app import views, models
# @app.route('/')
# def hello_world():
#     return 'Hello nimade  World!'
#
# class MyForm(Form):
#     name = StringField('name', validators=[DataRequired()])
#
# @app.route('/reg', methods=['POST', 'GET'])
# def reg():
#     form = MyForm()
#     if request.method == 'POST':
#         return redirect('/success')
#     else:
#         # 如果请求访求是 GET 或验证未通过就会执行下面的代码
#         return render_template('reg.html', form=form)
#
# @app.route('/success', methods=['POST', 'GET'])
# def success():
#     return 'ok'
#
#
# @app.route('/upload', methods=['GET', 'POST'])
# def upload_file():
#     if request.method == 'POST':
#         f = request.files['the_file']
#         f.save('/var/www/uploads/uploaded_file.txt')
#     else:
#         #greatdir('2016')
#         return render_template('upload.html')
#
#
#
# @app.route('/upload2', methods=['GET', 'POST'])
# def upload_file2():
#     if request.method == 'POST':
#         file = request.files['file']
#         if file and allowed_file(file.filename):
#             filename = secure_filename(file.filename)
#             re = file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
#             print(re)
#             return ''
#         else:
#             return 'bao cun shibai'
#
#     else:
#         #re = creatDir('2015/04')
#         re = Application.Common.function.creatDateDir()
#         return render_template('upload.html', re=re)
#
#
# if __name__ == '__main__':
#     app.debug = True
#     app.run()

#
# from flask import Flask
# from flask.ext.sqlalchemy import SQLAlchemy
#
# app = Flask(__name__)
# app.config['SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://zyx:zyx@localhost/test'
# app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = True
# db = SQLAlchemy(app)
#
#
# class User(db.Model):
#     id = db.Column(db.Integer, primary_key=True)
#     username = db.Column(db.String(80), unique=True)
#     email = db.Column(db.String(120), unique=True)
#
#     def __init__(self, username, email):
#         self.username = username
#         self.email = email
#
#     def __repr__(self):
#         return '<User %r>' % self.username
#
#
# from datetime import datetime
#
#
# class Post(db.Model):
#     id = db.Column(db.Integer, primary_key=True)
#     title = db.Column(db.String(80))
#     body = db.Column(db.Text)
#     pub_date = db.Column(db.DateTime)
#
#     category_id = db.Column(db.Integer, db.ForeignKey('category.id'))
#     category = db.relationship('Category',
#         backref=db.backref('posts', lazy='dynamic'))
#
#     def __init__(self, title, body, category, pub_date=None):
#         self.title = title
#         self.body = body
#         if pub_date is None:
#             pub_date = datetime.utcnow()
#         self.pub_date = pub_date
#         self.category = category
#
#     def __repr__(self):
#         return '<Post %r>' % self.title
#
#
# class Category(db.Model):
#     id = db.Column(db.Integer, primary_key=True)
#     fid = db.Column(db.Integer)
#     name = db.Column(db.String(50))
#
#     def __init__(self, name):
#         self.name = name
#
#     def __repr__(self):
#         return '<Category %r>' % self.name
#
# #创建所有数据表
# #db.create_all()
#
# #增加数据
# #admin = User('admin', 'admin@example.com')
# #guest = User('guest', 'guest@example.com')
#
# #db.session.add(admin)
# #db.session.add(guest)
# #db.session.commit()
#
# #获取数据
# users = User.query.all()
# print(users)
# admin = User.query.filter_by(username='admin').first()
# print(admin)
#
#
# py = Category('swift')
# re = p = Post('Hello swift3!', 'swift is pretty cooller', py)
# db.session.add(py)
# db.session.add(p)
# db.session.commit()
#
# data = py.posts.all()
# print(data)
# print(re)
#
